package com.agino.jdk8.learn.classlearn;

import com.agino.jdk8.learn.classlearn.objects.testinit.TestObject1;
import com.agino.jdk8.learn.classlearn.objects.testinit.TestObjectEnum;
import com.agino.jdk8.learn.utils.PrintUtils;

/**
 * 测试Class 的 forName() 方法
 *
 * @author qinl
 * @date 2022/4/8 10:13
 **/
public class TestClassForName {

    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {

        System.out.println(Class.forName("com.agino.jdk8.learn.classlearn.interfaces.TestInterface"));

        PrintUtils.printCutOffRule();

        Object instance = Class.forName("com.agino.jdk8.learn.classlearn.objects.TestObjectClass").newInstance();

        System.out.println(instance.toString());

        PrintUtils.printCutOffRule();

        System.out.println(TestObjectEnum.TEST_OBJECT_1.getClazz().newInstance().toString());

        PrintUtils.printCutOffRule();

        TestObject1 object1 = TestObject1.class.newInstance();

        System.out.println(object1.toString());


    }
}
